package cn.edu.zafu.bigdata.zqt.Error;

class InvalidAgentException extends Exception {
    public InvalidAgentException(String message) {
        super(message);
    }
}

public class Invalid {
    public static void checkAge(int age) throws InvalidAgentException {
        if(age<18) {
            throw new InvalidAgentException("是无效年龄，年龄必须大于等于18");
        }
    }
    public static void main(String[] args) {
        int age=17;
        try {
            checkAge(age);
        } catch (InvalidAgentException e) {
            System.out.println(age+e.getMessage());
        }
    }
}
